# 导包
import requests

import app


# 定义封装方法的类
class LoginApi:

    def __init__(self):
        self.url_login = app.BASE_HOST + "/api/sys/login"

    def login(self, json_dirt):
        return requests.post(url=self.url_login, json=json_dirt)

    # 获取token
    def get_token(self, json_dirt):
        res = self.login(json_dirt)
        token_value = res.json().get("data")

        return 'Bearer' + " " + token_value


if __name__ == '__main__':
    login_api = LoginApi()

    json_dirt = {"mobile": "13800000002", "password": "123456"}

    res = login_api.login(json_dirt)
    token = login_api.get_token(json_dirt)
    print(token)
